package com.up.upzl.biz.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import com.up.upzl.biz.domain.Customer;
import com.up.upzl.biz.service.CustomerService;

/**
 * 客源控制器
 * 
 * @author joker
 *
 */
@Controller
@RequestMapping("customer")
public class CustomerController {

	@Autowired
	private CustomerService customerService;

	/**
	 * 跳转list页面
	 * 
	 * @return
	 */
	@GetMapping("list")
	public String list(String account, Date beginTime, Date endTime, Pageable page, Model model) {
		page = new PageRequest(page.getPageNumber(), page.getPageSize(), new Sort(Direction.DESC, "createTime"));
		Page<Customer> list = customerService.findByCondition(account, beginTime, endTime, page);
		model.addAttribute("pageList", list);
		return "customer/list";
	}
}
